package cn.wolfcode.rbac.web.controller;

import cn.wolfcode.rbac.domain.CustomerTraceHistory;
import cn.wolfcode.rbac.query.CustomerTraceHistoryQuery;
import cn.wolfcode.rbac.service.ICustomerTraceHistoryService;
import cn.wolfcode.rbac.service.ISystemDictionaryItemService;
import cn.wolfcode.rbac.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/customerTraceHistory")
public class CustomerTraceHistoryController {
    @Autowired
    private ICustomerTraceHistoryService service;
    @Autowired
    private ISystemDictionaryItemService sdiService;


    @RequestMapping("/list")
    public String list(@ModelAttribute("qo") CustomerTraceHistoryQuery qo, Model model){
        model.addAttribute("result",this.service.query(qo));
        model.addAttribute("traceTypes",this.sdiService.findFromSDI(26));
        return "customerTraceHistory/list";
    }


    @RequestMapping("/saveOrUpdate")
    @ResponseBody
    public JsonResult saveOrUpdate(CustomerTraceHistory cth){
        this.service.saveOrUpdate(cth);
        return new JsonResult();
    }
}
